import React from 'react'

import  {incrementAction,decrementAction,waitIncrementAction} from "../../store/actions/countAction"
import store from '../../store/store'

export default function Count() {
    const {count} = store.getState().count
    const incrementHandle=()=>{
        store.dispatch(incrementAction())
    }

    const decrementHandle=()=>{
        store.dispatch(decrementAction())
    }
    const oddincrementHandle=()=>{
        if (count%2!==0) {
            store.dispatch(incrementAction())
        }
    }
    const waitincrementHandle=()=>{
        store.dispatch(waitIncrementAction())
    }

  return (
    <div>
        <h1>这是一个数{count}</h1>
        <button onClick={incrementHandle}>累加</button>
        <button onClick={decrementHandle}>累减</button>
        <button onClick={oddincrementHandle}>奇数累加</button>
        <button onClick={waitincrementHandle}>2s后累加</button>
    </div>
  )
}
